$(function(){
    var base_url = $("#base_url").val();

    $('.act').click(function(event){
        var data = {
            event         : 1,
            type          : $('.curr').attr("type"),
            name          : $.trim($("#name").val()),
            phone         : $.trim($("#phone").val()),
            address           : $.trim($("#add").val())
        };
        if (!data.type) {
            alert("请选择商品")
            return false;
        }
        if (!data.name) {
            alert("请输入姓名")
            return false;
        }
        if (!data.address) {
            alert("请输入地址")
            return false;
        }
        if (!data.phone) {
            alert("输入手机号")
            return false;
        }
        if (!data.phone.match(/^(((13[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/)) {
            alert("手机号码格式不正确！");
            return false;
        }


        $.ajax({
            url: base_url+"/index.php/m/index/save",
            data: data,
            type: 'post',
            success: function (msg) {
                var obj = JSON.parse(msg);
                if(obj.code == 1){
                    location.href = obj.url;
                }else{
                    alert(obj.data);
                }
            }
        });
    });



})